package com.mine.ability.controllers;

import com.mine.ability.model.Employee;
import com.mine.ability.services.EmployService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @功能
 * @创建时间 2020/4/13
 */
@RestController
@RequestMapping("/ablivity" )
public class AbilityController {
    @Autowired
    private RabbitTemplate amqpTemplate;
    @Autowired
    EmployService employService;

    @Value("${server.port}")
    private String port;

    @Value("${spring.cloud.client.ip-address}") //spring cloud 自动的获取当前应用的ip地址
    private String ip;

    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public Employee find(@PathVariable Integer id)  {
//        try {
//            Thread.sleep(2000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        Employee employee = employService.findById(id);
        employee.setAddress(port+":"+ip);
        return employee;

    }

}
